package api_;

import java.util.Random;
import java.util.Scanner;

public class RandomCode
{
    public static void main(String[] args)
    {
        char[] code = new char[4];
        String src = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM1234567890";
        System.out.println(26 + 26 + 10); // 62
        for (int i = 0; i < 4; i++)
        {
            int index = new Random().nextInt(63);
            code[i] = src.charAt(index);
        }
        boolean fit = false;
        while(fit != true)
        {
            StringBuilder result = new StringBuilder();
            for (int i = 0; i < code.length; i++)
            {
                result.append(code[i]);
            }
            System.out.println(result);
            String resultString = result.toString();
            System.out.println("请输入验证码: ");
            String input = new Scanner(System.in).next();
            if (resultString.equalsIgnoreCase(input))
            {
                System.out.println("right");
                fit = true;
            }
            else {
                System.out.println("false");
            }
        }

    }
}
